<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.lgx.right.entity.User"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="<%=basePath %>style/shopping-cart.css" type="text/css" rel="stylesheet" /><!-- 购物车样式 -->
	<jsp:include page="/page/jsp/member/head.jsp" />
	<script type="text/javascript">
	    //删除购物车中的单个商品
		function deleteProduct(id){
			if(id != ""){
				$.ajax({
					   url: path+"/cart/delete.htm?id="+id,
					   success: function(data){
						   if(data=="0"){
							   alertBox("删除成功!");
							   window.location = path+"/cart/list.htm";
						   }else if(data=="1"){
							   alertBox("商品不存在失败!");
						   }else{
							   alertBox("删除失败!");
						   }
					   }
				});
			}
		}
	    
	    //删除购物车中的全部商品
	    function deleteProductAll(){
	    	$.ajax({
				   url: path+"/cart/deleteAll.htm",
				   success: function(data){
					   if(data=="0"){
						   alertBox("删除成功!");
						   window.location = path+"/cart/list.htm";
					   }else{
						   alertBox("删除失败!");
					   }
				   }
			});
	    }
		
		function continueShop(){
			parent.window.location = path;
		}
		
		
		//去结算
		function settlement(orderId){
			 window.location = path+"/cart/orderConfirm.htm?orderId="+orderId;
		}
	</script>
  </head>
  
  <body>
   <div class="right">
	<h1><b>我的购物车</b><span><img src="<%=basePath%>images/right_h1bg2.jpg" width="3" height="29" /></span></h1>
	<div class="ri_main">
		<ol class="flow-steps">
			<li class="s1 cur">购物车</li>
			<li class="s2 suc">确认订单信息</li>
			<li class="s3 suc">成功提交订单</li>
		</ol>
	  <table width="100%" border="0" cellpadding="8" cellspacing="1" class="margintop10" style="background:#d9d9d9;">
	    <tr>
	      <td width="12%" bgcolor="#eeeeee"><b>图片</b></td>
	      <td width="45%" bgcolor="#eeeeee"><b>商品名称</b></td>
	      <td width="5%" bgcolor="#eeeeee"><b>单价</b></td>
	      <td width="5%" bgcolor="#eeeeee"><b>数量</b></td>
	      <td width="8%" bgcolor="#eeeeee"><b>小计</b></td>
	      <td width="10%" bgcolor="#eeeeee"><b>操作</b></td>
	    </tr>
	    <c:forEach var="cart" items="${orderDetails}">
		    <tr>
		    	<td bgcolor="#FFFFFF"><img src="${img_server_url}/${cart.entityImg}" width="70" height="70" /></td>
		    	<td bgcolor="#FFFFFF">${cart.entityName}</td>
		    	<td bgcolor="#FFFFFF">${cart.price}</td>
		    	<td bgcolor="#FFFFFF">${cart.amount}</td>
		    	<td bgcolor="#FFFFFF">${cart.predict()}</td>
		    	<td bgcolor="#FFFFFF"><input type="button" name="button4" id="button4" onclick="deleteProduct(${cart.id})" value="删除" /></td>
		    </tr>
	    </c:forEach>
	  </table>
	  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="5" class="margintop10 lineheight22">
	    <tr>
	      <td align="right">商品数量总计：<b class="redfont">${order.amount}</b>件 商品金额总计(不含运费)：<b class="redfont">${order.score}</b>  积分</td>
	    </tr>
	    <tr>
	      <td align="right"><a href="javascript:void(0);" onclick="deleteProductAll()" class="gw_btn">清空购物车</a><a href="javascript:continueShop();" class="gw_btn2">继续购物</a><input name="button" type="submit" class="gw_btn3" id="button" value="" onclick="settlement(${order.id})" /></td>
	    </tr>
	  </table>
	</div>
	</div>
  </body>
</html>
